<?php

namespace App\Validate;

use App\Validate\BaseValidate;

/**
 * 展览屏幕验证器
 */
class ExhibitionValidate extends BaseValidate
{
  //验证规则
  protected $rule = [
    'id' => 'bail|required|integer',
    'production_id' => 'bail|required',
    'name' => 'bail|required',
    'type_name' => 'bail|required',
    'address' => 'bail|required',
    'start_time' => 'bail|required|date_format:Y-m-d H:i:s',
    'end_time' => 'bail|required|date_format:Y-m-d H:i:s|after:start_time',
    'opening_time' => 'bail|required|date_format:Y-m-d H:i:s',
    'roll_speed' => 'bail|required|integer|between:10,100',
    'page_stay_min_time' => 'bail|required|integer|min:5',
    'status' => 'bail|required|in:1,2',
  ];
  //自定义验证信息
  protected $message = [
    'id.required' => '展览编号不能为空',
    'id.integer' => '展览编号格式不正确',
    'production_id.required' => '作品编号不能为空',
    'name.required' => '展览名称不能为空',
    'type_name.required' => '类型名称不能为空',
    'address.required' => '展览地址不能为空',
    'start_time.required' => '展览开始时间不能为空',
    'start_time.date_format' => '展览开始时间格式不正确',
    'end_time.required' => '展览结束时间不能为空',
    'end_time.date_format' => '展览结束时间格式不正确',
    'end_time.after' => '展览结束时间不能小于开始时间',
    'opening_time.required' => '开幕时间不能为空',
    'opening_time.date_format' => '开幕时间格式不正确',
    'roll_speed.required' => '滚动速度不能为空',
    'roll_speed.integer' => '滚动速度规则不能正确',
    'roll_speed.between' => '滚动速度时间只能在10~100之间',
    'page_stay_min_time.required' => '页面停留时间不能为空',
    'page_stay_min_time.integer' => '页面停留时间设置不正确',
    'page_stay_min_time.min' => '页面停留时间最小是5秒',
    'status.required' => '状态不能为空',
    'status.in' => '状态错误',
  ];



  //自定义场景
  protected $scene = [
    'exhibition_info' => ['id'], //获取展览详情
    'exhibition_add' => ['name','type_name','address','start_time','end_time','roll_speed','page_stay_min_time'], //展览添加
    'exhibition_change' => ['id','name','type_name','address','start_time','end_time','roll_speed','page_stay_min_time'], //展览修改
    'exhibition_del' => ['id'], //展览删除
    'exhibition_config_production' => ['id'], //配置展览作品
    'exhibition_config_bookcase' => ['id'], //配置展览机柜
    'exhibition_del_production' => ['id','production_id'], //配置删除作品
    'exhibition_add_production' => ['id','production_id'], //配置添加作品
    'status_change' => ['id','status'], //展览状态修改
  ];
}
